package com.qf.shop.system.modules.catgory.service.impl;

import com.qf.shop.system.utils.PageUtils;
import com.qf.shop.system.utils.Query;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.qf.shop.system.modules.catgory.dao.CatgoryDao;
import com.qf.shop.system.modules.catgory.entity.CatgoryEntity;
import com.qf.shop.system.modules.catgory.service.CatgoryService;
import org.springframework.util.ObjectUtils;


@Service("catgoryService")
public class CatgoryServiceImpl extends ServiceImpl<CatgoryDao, CatgoryEntity> implements CatgoryService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<CatgoryEntity> page = this.page(
                new Query<CatgoryEntity>().getPage(params),
                new QueryWrapper<CatgoryEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<CatgoryEntity> gethomeList(int value) {
        if (ObjectUtils.isEmpty(value)) {
            return null;

        }
        //每组八个
        return baseMapper.getHomeList(value * 8);
    }

    @Override
    public List<CatgoryEntity> treeList() {
        return baseMapper.treeeList();
    }
}